#ifndef ZHEN_VM_H
#define ZHEN_VM_H
#include <stdint.h>
#include "base.h"
#include "csr.h"


struct riscv_Core{
    uint32_t pc;    // 程序计数器
    uint32_t reg[32];   // 32个通用寄存器
    uint32_t inst;  // 当前指令
    struct csr *csr; // 控制寄存器
    struct device **devices;    // 设备列表
};
struct riscv_Core *core_init(void);
void timer_init(void);
void run_inst(struct riscv_Core *RISCV);
void dev_init(struct device **devices);
void dev_register(struct device **devices,struct device *dev);
uint8_t dev_read_b(struct device **devices,uint32_t addr);
uint16_t dev_read_h(struct device **devices,uint32_t addr);
uint32_t dev_read_w(struct device **devices,uint32_t addr);
void dev_write_b(struct device **devices,uint32_t addr, uint8_t data);
void dev_write_h(struct device **devices,uint32_t addr, uint16_t data);
void dev_write_w(struct device **devices,uint32_t addr, uint32_t data);
#endif
